package cn.evolify.jfinaldemo.base;

import cn.evolify.jfinaldemo.controller.IndexController;
import cn.evolify.jfinaldemo.controller.UserController;
import cn.evolify.jfinaldemo.model._MappingKit;
import com.jfinal.config.*;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.render.ViewType;
import com.jfinal.template.Engine;

/**
 * Created by wolf on 2017/2/21.
 */
public class BaseConfig extends JFinalConfig {

    public void configConstant(Constants constants) {
        constants.setDevMode(true);
    }

    public void configRoute(Routes routes) {
        routes.setBaseViewPath("/WEB-INF/view");
        routes.add(R.ControllerKey.INDEX, IndexController.class);
        routes.add(R.ControllerKey.USER, UserController.class);
    }

    public void configEngine(Engine engine) {

    }

    public void configPlugin(Plugins plugins) {
        DruidPlugin druidPlugin=new DruidPlugin(
                PropKit.use("config.properties").get("jdbcUrl"),
                PropKit.get("user"),
                PropKit.get("password").trim()
        );
        plugins.add(druidPlugin);
        ActiveRecordPlugin activeRecordPlugin=new ActiveRecordPlugin(druidPlugin);
        _MappingKit.mapping(activeRecordPlugin);
        plugins.add(activeRecordPlugin);
    }

    public void configInterceptor(Interceptors interceptors) {

    }

    public void configHandler(Handlers handlers) {

    }
}
